package 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * Main demo
	 * @author wilson
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			// set stage property
			this.stage.align = StageAlign.TOP_LEFT;
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			this.stage.stageWidth = 640;
			this.stage.stageHeight = 80;
			
			// test compoment
			m_texBoard = new TextInfoBoard();
			addChild(m_texBoard);
			
			// simulate as a button
			m_button = new Sprite();
			m_button.graphics.beginFill(0x888888);
			m_button.graphics.drawRect(0, 0, 80, 50);
			m_button.graphics.endFill();
			m_button.addEventListener(MouseEvent.CLICK, clickButton);
			m_button.x = 300;
			addChild(m_button);
		}
		
		private function clickButton(e:MouseEvent):void
		{
			// add a string to show on screen
			m_texBoard.addShow("a new line" + m_count + "\n" );
			m_count++;
		}
		
		private var m_button:Sprite;
		private static var m_count:int = 0;
		private var m_texBoard:TextInfoBoard;
	}
	
}